﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TaxiCaosSOAPService.Dominio;
using NHibernate;
using TaxiCaosSOAPService.Exceptions;
using System.ServiceModel;

namespace TaxiCaosSOAPService.Persistencia
{
    public class TarifarioDAO : BaseDAO<Tarifario, int>
    {
        public Tarifario ObtenerPorOrigenDestino(string codigoOrig, string codigoDest)
        {
            using (ISession sesion = NHibernateHelper.ObtenerSesion())
            {
                string sentenciaSQL = "from Tarifario as t where t.IdOrigen = :idOrigen and t.IdDestino = :idDestino";
                IQuery query = sesion.CreateQuery(sentenciaSQL);
                query.SetParameter("idOrigen", codigoOrig);
                query.SetParameter("idDestino", codigoDest);
                IList<Tarifario> lista = query.List<Tarifario>();
                
                return (lista.Count > 0) ? lista[0] : null;

             }
        }

     }
}